using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(EffectPlayableAsset))]
public class EffectPlayableAssetEditor : Editor
{
    private SerializedObject temp;
    //private SerializedProperty
    public SerializedProperty res_path;
    public SerializedProperty trigger;
    public SerializedProperty use_prop_id;//0则没有该条件的判断


    public SerializedProperty spawn_point_type;
    public SerializedProperty spawn_hang_point;  
    public SerializedProperty rotate_type;
    public SerializedProperty position_offset;



    [Header("生成方式:0单发 1多发散射 2矩形队列 3范围内随机")]
    public SerializedProperty create_type;

    public SerializedProperty fan_count;
    public SerializedProperty fan_angle_difference;

    public SerializedProperty rect_rows;
    public SerializedProperty rect_columns;
    public SerializedProperty rect_rows_spacing;
    public SerializedProperty rect_columns_spacing;

    public SerializedProperty random_radius;
    public SerializedProperty random_radius_max;
    public SerializedProperty random_count;
    public SerializedProperty random_count_max;
    public SerializedProperty random_angle;
    public SerializedProperty random_angle_max;

    //----------------------------------------------这些想加再加
    //[Space(30)]
    //[Header("移动的方式:0按方向移动 1追踪移动 2围绕旋转 3贝塞尔曲线移动 4跟随移动")]
    //public int move_type; 
    //[Header("按方向-移动")]
    //public DirectMoveConfg directMoveConfg;

    //[Header("追踪目标-移动")]
    //public TrackMoveConfig trackMoveConfig;
    //[Header("围绕旋转-移动")]
    //public AroundMoveConfig aroundMoveConfig;
    //[Header("曲线-移动")]
    //public BezierCurveMoveConfig bezierCurveMoveConfig;

    //[Header("跟随-移动")]
    //public FollowTweenConfig followTween;

    //[Space(30)]
    //[Header("命中时的特效")]
    //public SerializedProperty hit_effect;
    //[Header("命中时特效数量:0无限制 1只创建一次")]
    //public SerializedProperty hit_effect_count;
    //[Header("命中时的音效")]
    //public SerializedProperty hit_audio;

    //[Header("同一个单位允许被命中几次")]
    //public SerializedProperty unit_hit_count;


    //[Space(30)]
    //[Header("销毁-存活时间")]
    //public SerializedProperty destroy_durtaion;

    //[Header("销毁-命中多少个单位")
    //public SerializedProperty destroy_hit_count;


    private void OnEnable()
    {
        temp = new SerializedObject(target);
        var _config = temp.FindProperty("Config");


        res_path = _config.FindPropertyRelative("res_path");
        trigger = _config.FindPropertyRelative("trigger");
        use_prop_id = _config.FindPropertyRelative("use_prop_id");


        spawn_point_type = _config.FindPropertyRelative("spawn_point_type");
        spawn_hang_point = _config.FindPropertyRelative("spawn_hang_point");
        rotate_type = _config.FindPropertyRelative("rotate_type");
        position_offset = _config.FindPropertyRelative("position_offset");

        create_type = _config.FindPropertyRelative("create_type");

        fan_count = _config.FindPropertyRelative("fan_count");
        fan_angle_difference = _config.FindPropertyRelative("fan_angle_difference");

        rect_rows = _config.FindPropertyRelative("rect_rows");
        rect_columns = _config.FindPropertyRelative("rect_columns");
        rect_rows_spacing = _config.FindPropertyRelative("rect_rows_spacing");
        rect_columns_spacing = _config.FindPropertyRelative("rect_columns_spacing");


        random_radius = _config.FindPropertyRelative("random_radius");
        random_radius_max = _config.FindPropertyRelative("random_radius_max");
        random_count = _config.FindPropertyRelative("random_count");
        random_count_max = _config.FindPropertyRelative("random_count_max");
        random_angle = _config.FindPropertyRelative("random_angle");
        random_angle_max = _config.FindPropertyRelative("random_angle_max");

    }

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        temp.Update();

        #region 展示逻辑
        EditorGUILayout.PropertyField(res_path);
        EditorGUILayout.PropertyField(trigger);
        EditorGUILayout.PropertyField(use_prop_id);

        EditorGUILayout.PropertyField(spawn_point_type);
        EditorGUILayout.PropertyField(spawn_hang_point);
        EditorGUILayout.PropertyField(rotate_type);
        EditorGUILayout.PropertyField(position_offset);
        EditorGUILayout.PropertyField(fan_angle_difference);

        EditorGUILayout.PropertyField(create_type);
        switch (create_type.intValue)
        {
            case 0:
                break;
            case 1:
                EditorGUILayout.PropertyField(fan_count);
                EditorGUILayout.PropertyField(fan_angle_difference);
                break;
            case 2:
                EditorGUILayout.PropertyField(rect_rows);
                EditorGUILayout.PropertyField(rect_columns);
                EditorGUILayout.PropertyField(rect_rows_spacing);
                EditorGUILayout.PropertyField(rect_columns_spacing);
                break;
            case 3:
                EditorGUILayout.PropertyField(random_radius);
                EditorGUILayout.PropertyField(random_radius_max);
                EditorGUILayout.PropertyField(random_count);
                EditorGUILayout.PropertyField(random_count_max);
                EditorGUILayout.PropertyField(random_angle);
                EditorGUILayout.PropertyField(random_angle_max);
                break;


        }
        #endregion

    serializedObject.ApplyModifiedProperties();
        temp.ApplyModifiedProperties();
    }

}
